package com.zxc.flowSum;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class FlowSum implements Writable {
    private long up;
    private long low;
    private long sum;

    public FlowSum(long up, long low) {
        super();
        this.up = up;
        this.low = low;
        this.sum = up + low;
    }

    public FlowSum() {
        super();
    }

    public long getUp() {
        return up;
    }

    public void setUp(long up) {
        this.up = up;
    }

    public long getLow() {
        return low;
    }

    public void setLow(long low) {
        this.low = low;
    }

    public long getSum() {
        return sum;
    }

    public void setSum(long sum) {
        this.sum = sum;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(up);
        dataOutput.writeLong(low);
        dataOutput.writeLong(sum);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        up = dataInput.readLong();
        low = dataInput.readLong();
        sum = dataInput.readLong();
    }

    @Override
    public String toString() {
        return up + "\t" + low + "\t" + sum;
    }

    public void setAll(long up, long low) {
        this.up = up;
        this.low = low;
        this.sum = up + low;
    }
}
